package com.guaoran.study.future;

import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

/**
 * @author : 孤傲然
 * @description : TODO 加上描述吧
 * @date :2021/3/25 10:57
 */
public class Test {
    public static void main(String[] args) {
        ExecutorService verifyExecutor = Executors.newFixedThreadPool(4);
        List<Integer> finalList = new ArrayList<>();
        for (int i = 0; i < 10; i++) {
            finalList.add(i);
        }
        for (Integer v : finalList) {
            CompletableFuture.runAsync(() -> {
                    System.out.println(v);
            }, verifyExecutor);
        }
//        CompletableFuture.runAsync(() -> {
//            for (Integer v : finalList) {
//                System.out.println(v);
//            }
//        }, verifyExecutor);
        while(!verifyExecutor.isShutdown()){
            verifyExecutor.shutdown();
        }
    }
}
